#include <cstdio>
#include "Mixin_UnitTest.hh"

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>

void testMixin( SimpleNode& aNode )
{
    Mixin1< SimpleNode >* lMixin1 = aNode.castTo< Mixin1< SimpleNode > >();
    Mixin0< SimpleNode >* lMixin0 = aNode.castTo< Mixin0< SimpleNode > >();
    Mixin1< SimpleNode >* lMixin11 = aNode.castTo< Mixin1< SimpleNode > >();
    Mixin0< SimpleNode >* lMixin00 = aNode.castTo< Mixin0< SimpleNode > >();
    lMixin0->fireMixin0();
    lMixin1->fireMixin1();
    lMixin00->fireMixin0();
    lMixin11->fireMixin1();
    lMixin11->fireMixin1();

    lMixin1->addOne();
    lMixin0->addOne();
}

void testMixin0( Mixin0< SimpleNode >& aMixin0 )
{
    aMixin0.addOne();
}

void testMixin1( Mixin1< SimpleNode >& aMixin1 )
{
    aMixin1.addOne();
}


BOOST_AUTO_TEST_CASE( Mixin_test )
{
    mixedSimpleNode testNode;
    testMixin( testNode );
    testMixin0( testNode );
    testMixin1( testNode );

    BOOST_CHECK( testNode.getVal() == 4 );
    BOOST_CHECK( testNode.castTo< Mixin0< SimpleNode > >()->getValue() == 2 );
    BOOST_CHECK( testNode.castTo< Mixin1< SimpleNode > >()->getValue() == 3 );
}
